#!/usr/bin/python3
import RPi.GPIO as GPIO
import time


def key_callback(key):
    global KEY1,KEY2,LED1,LED2
    if key == KEY1 :
        LED=LED1
    elif key ==KEY2 :
        LED=LED2
    

    if GPIO.input(key):
        print("LED on")
        GPIO.output(LED, 0)
    else:
        print('LED off')
        GPIO.output(LED, 1)



KEY1=6
LED1=5
KEY2=13
LED2=22

if __name__ == "__main__":
    
    GPIO.setwarnings(False)

    GPIO.setmode(GPIO.BCM)

    GPIO.setup(KEY1, GPIO.IN, GPIO.PUD_UP)
    GPIO.setup(KEY2, GPIO.IN, GPIO.PUD_UP)

    GPIO.add_event_detect(KEY1, GPIO.BOTH, key_callback,bouncetime = 20)
    GPIO.add_event_detect(KEY2, GPIO.BOTH, key_callback,bouncetime = 20)

    GPIO.setup(LED1, GPIO.OUT)
    GPIO.setup(LED2, GPIO.OUT)

    #GPIO.add_event_callback(KEY1,callback = key_callback)

    print("while--------\n")
    while True :
        time.sleep(0.05)
        







